/**
 * Created by Administrator on 2015/9/29.
 */
'use strict';

var koa = require('koa');
var bodyParser = require('koa-bodyparser');
var json = require('koa-json');
var jwt = require('jsonwebtoken');
//var hbs = require('koa-hbs');
//var staticCache = require('koa-static-cache');
//var logger = require('koa-logger');
//var error = require('koa-error');
//var gzip = require('koa-gzip');
//var session = require('koa-session');
//var passport = require('koa-passport');

var router = require('./router');
var config = require('./config');

var app = koa();

//设置出错页面
//app.use(error());

//设置静态文件路径
//app.use(staticCache(path.join('./public')));

//设置hbs页面模板引擎
//app.use(hbs.middleware({
//    viewPath: ['./client/web','./client/wx'],
//    extname: '.html',
//    disableCache: false //开发时启用,正式环境上可以取消
//}));

//设置解析客户端post数据
app.use(bodyParser());

//设置session
//app.keys = ['tonykey'];
//app.use(session(app));

//设置passport,用于登录验证
//app.use(passport.initialize());
//app.use(passport.session());

//设置路由服务
app.use(router.routes());

//启动日志记录
//app.use(logger());

//响应JSON
app.use(json());


//设置gzip压缩,一定要设置为最后一个加载的中间件
//app.use(gzip());

//启动监听端口
app.listen(7777);
console.log('启动成功,监听7777端口');